<?php
defined('IN_DESTOON') or exit('Access Denied');
/***
 * 时间转换函数
 * by lmx at 20180522
 * @param $time
 * @return false|string
 */
function format_date($time){
    $t = time() - $time;
    $f = array(
//        '31536000' => '年',
//        '2592000' => '个月',
//        '604800' => '星期',
//        '86400' => '天',
        '3600' => '小时',
        '60' => '分钟',
        '1' => '秒'
    );
    if($t<=86400){
        foreach ($f as $k => $v) {
            if (0 != $c = floor($t / (int)$k)) {
                return $c . $v . '前';
            }
        }
    }else{
        return timetodate($time, 3);
    }

}
/**
 * 20180323 模板调用标题，默认调用title
 * @param $t
 * @param string $type
 */
function title($t, $type = 'title')
{
    switch ($type) {
        case 'headline':
            echo $t['headline'] == '' ? $t['title'] : $t['headline'];
            break;
        case 'subhead':
            echo $t['subhead'] == '' ? $t['title'] : $t['subhead'];
            break;
        case 'mobtitle':
            echo $t['mobtitle'] == '' ? $t['title'] : $t['mobtitle'];
            break;
        default:
            echo $t['title'];
            break;
    }
}

?>